﻿@TestRunner.Imports


namespace @Test.Namespace
{
    public partial class @Test.ClassName
    {
        @{
 
            foreach (var property in Class.Properties.Where(p => !p.IsIndexer && p.CanRead && p.CanWrite && (p.IsNullable || p.Type.HasCommonValues)))
            {
                if (property.IsNullable) 
                { 
                    <text>
                    @Tag("PropertyAssign")
                    @TestAttribute
                    public void @(Test.ClassName + "_Property_" + property.Name + "_PropertyNullAssigned") ()
                    {
                        var objectUnderTest = CreateObject();
                        try
                        {
                            objectUnderTest.@property.Name = null;
                            @Assert.IsNull("objectUnderTest." + @property.Name);
                        }
                        catch (System.ArgumentNullException)
                        {
                            //OK
                            return;
                        }
                    }    
                    </text>
                }

                if (property.Type.HasCommonValues) 
                {
					var testCount = 1;


					foreach (var testValue in property.Type.CommonValues)
					{ 
						<text>
						@Tag("PropertyAssign")
						@TestAttribute
						public void @(Test.ClassName + "_Property_" + property.Name + "_PropertyAssigned_" + testCount) ()
						{
							var objectUnderTest = CreateObject();
							@property.Type.FullName expectedValue;
						</text>



							<text>
							try
							{
								expectedValue = @testValue;
								objectUnderTest.@property.Name = expectedValue;
								@Assert.AreEqual(@property.Type, "expectedValue", "objectUnderTest." + @property.Name);
							}
							catch (System.ArgumentException)
							{
								//OK
								return;
							}
							</text>

                           
						<text>
						}    
						</text>
			
						testCount++;
					}
                }
            }
        }
    }
}

